package cn.touna.jss.common.model;

import java.util.List;

public class PageResult {
    private int pageNum;
    private int pageSize;
    private int total;
    private int pages;
    private List list;

    public int getPageNum() {
        return pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public int getTotal() {
        return total;
    }

    public int getPages() {
        return pages;
    }

    public List getList() {
        return list;
    }

    /**
     * 构建分页结果
     *
     * @param page
     * @param total
     * @param list
     * @return
     */
    public static PageResult build(Page page, int total, List list) {
        PageResult result = new PageResult();
        result.pageNum = page.getPageNum();
        result.pageSize = page.getPageSize();
        result.total = total;
        result.pages = (int) Math.ceil((double) total / page.getPageSize());
        result.list = list;
        return result;
    }
}
